package com.moonspeak.boot.logwatch;

import cn.hutool.core.io.LineHandler;

import javax.websocket.Session;
import java.io.IOException;

/**
 * 日志数据行处理器
 */
public class WebSocketLineHandler implements LineHandler {

    private final Session session;

    public WebSocketLineHandler(Session session) {
        this.session = session;
    }

    @Override
    public void handle(String line) {
        try {
            session.getBasicRemote().sendText(line);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}